package com.jobjoin.jobjoin.user.controller;


import com.jobjoin.jobjoin.common.util.R;
import com.jobjoin.jobjoin.user.entity.Feature;
import com.jobjoin.jobjoin.user.service.FeatureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 功能表 前端控制器
 * </p>
 *
 * @author WinsomeC
 * @since 2021-04-18
 */
@RestController
@RequestMapping("/user/feature")
public class FeatureController {
    @Autowired
    private FeatureService featureService;

    @PostMapping("/addFeature")
    public R addFeature(Feature feature){
        boolean save = featureService.save(feature);
        if(save){
            return R.ok();
        }else{
            return R.error();
        }
    }
    @GetMapping
    public R getFeature(){
        List<Feature> list = featureService.list(null);
        return R.ok().data("items",list);
    }

    @DeleteMapping("{id}")
    public boolean deleteFeatureById(@PathVariable String id){
        boolean b = featureService.removeById(id);
        return b;
    }

}

